//
//  MEFlickrConnection.m
//  FlickrImport
//
//  Created by Sandeep Chayapathi on 1/18/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "MEFlickrConnection.h"
#import "PreferenceController.h"

@implementation MEFlickrConnection

- (id) initWithDelegate: (id) delegate {
    self = [super init];
    
    NSString *api_key = @"8f05692f343813719b916b41415e9720";
    NSString *shared_secret = @"f96644c5c77e07f0";
    
    context = [OFFlickrContext contextWithAPIKey:api_key 
                                     sharedSecret: shared_secret];
    
    invoc = [OFFlickrInvocation invocationWithContext:context
                                              delegate: delegate];

    [context setAuthToken: [[NSUserDefaults standardUserDefaults] stringForKey: MEFlickrToken]];
    
    return self;
}

- (void) dealloc {
    [context release];
    [invoc release];
    
    [super release];
}

- (OFFlickrContext *) context; {
    return context;
}

- (OFFlickrInvocation *) invoc; {
    return invoc;
}

+ (id) getConnectionWithDelegate: (id) delegate; {
    static MEFlickrConnection *connection = nil;

    if(!connection){
        connection = [[self alloc] initWithDelegate: delegate];
    }
        
    return connection;

}
@end
